<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>"> 
    <title>诊疗界面</title>  
    <link rel="stylesheet" href="<%=path %>/plugins/layui/css/layui.css" media="all">
  </head>

  <script src="<%=path %>/plugins/layui/layui.js"></script>
  
  <body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>填写诊疗信息界面</legend>
</fieldset>
<form class="layui-form layui-form-pane" id="TreatForm" lay-filter="example" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">学生学号</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="stuId" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">学生姓名</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="stuName" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="standPrice">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">性别</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="stuSex" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">年龄</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="stuAge" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">医师编号</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="userId" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">医师姓名</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="userName" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="standPrice">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">诊疗方法</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="treatMethod" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">诊疗结果</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="treatResult" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">挂号编号</label>
    <div class="layui-input-inline">
      <input style="width:500px;" type="text" name="regId" readonly="readonly" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
    </div>
  </div>
  <div class="layui-form-item" align="center">
    <button class="layui-btn" lay-submit="" lay-filter="submit">保存信息</button>
  </div>
  </form>
</body>
  
<script>
layui.use(['form', 'layedit', 'laydate', 'jquery'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,$ = layui.jquery;
 
  //监听提交
  form.on('submit(submit)', function(data){

	$.ajax({
		url: '<%=path%>/biz/Treat_add.action',
		type: 'POST',
		data: $('#TreatForm').serialize(),
		dataType: 'json',
		success: function(data){
			var json = eval("("+data+")");
			//添加成功
			if(json.isSucceed){
				layer.open({
			        content: '<div style="padding: 20px 100px;">修改成功~</div>'
			        ,btn: '朕知道了'
			        ,btnAlign: 'c' //按钮居中
			        ,shade: 0 //不显示遮罩
			        ,yes: function(){
			        	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 
						parent.layer.close(index);//再执行关闭当前iframe页面  
						parent.location.reload();//刷新父页面
			        }
			      });
			}else{
				message("添加失败~不解释");
				//关闭当前iframe弹出层
				parent.layer.close();
			}
		},
		error: function(data){
			layer.msg("请求失败");
		}
	});
    return false;//阻止表单跳转
  }); 
  
  
  //信息提示弹出层
  function message(data){
      layer.open({
        content: '<div style="padding: 20px 100px;">'+ data +'</div>'
        ,btn: '朕知道啦'
        ,btnAlign: 'c' //按钮居中
        ,shade: 0 //不显示遮罩
        ,yes: function(){
          layer.closeAll();
        }
      }); 
  }

  
  $('#layerDemo .layui-btn').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
  
    //表单初始赋值
  form.val('example', {
     "stuId": '${student.stuId}' // "name": "value"
    ,"stuName": '${student.stuName}'
    ,"userId": '${user.userId}'
    ,"userName": '${user.userRealName}'
    ,"regId": '${regId}'
    ,"stuSex": '${student.stuSex}'
    ,"stuAge": '${student.stuAge}'
  });
  
});
</script>
</html>
